import { Router, Route, Switch, Redirect } from 'react-router-dom'
import React, { Suspense } from 'react'
// import NoMatch from './pages/NoMatch/index'
import AuthRoute from 'components/AuthRoute/AuthRoute'
import history from 'utills/history'
//将 Layout Login 设置成懒加载
// import Layout from './pages/Layout/index'
// import Login from './pages/Login/index'
const Layout = React.lazy(() => import('pages/Layout/index'))
const Login = React.lazy(() => import('pages/Login/index'))
function App() {
  return (
    <Router history={history}>
      {/* <Link to="/login">登录</Link>
      <Link to="/home">首页</Link> */}
      <Suspense fallback={<div>Loading...</div>}>
        <Switch>
          <Redirect exact from="/" to="/login"></Redirect>
          {/* <Route
          path="/login"
          render={(props) => {
            return <Login {...props} />
          }}
        ></Route> */}
          <Route path="/login" component={Login}></Route>
          <AuthRoute path="/home" component={Layout}></AuthRoute>
          {/* <Route component={NoMatch} /> */}
        </Switch>
      </Suspense>
      {/* 配置路由规则 */}
    </Router>
  )
}

export default App
